﻿using System;
using System.Collections.Generic;
using Random = UnityEngine.Random;

namespace TowerDefence_Zombie
{
    public class MoneyInfo
    {
        public int MoneyId;

        public int CountMin;

        public int CountMax;

        public int Count;
        public MoneyInfo(int MoneyId ,int CountMin, int CountMax)
        {
            this.MoneyId = MoneyId;
            this.CountMin = CountMin;
            this.CountMax = CountMax;
            Count = Random.Range(CountMin, CountMax);
        }
    }

    public sealed class TreasureBoxData
    {
        private DRTreasureBox dRTreasureBox;

        public int TreasureBoxId
        {
            get { return dRTreasureBox.Id; }
        }

        public string IconResId
        {
            get { return dRTreasureBox.BoxIcon; }
        }

        public string OpenIconRes
        {
            get { return dRTreasureBox.BoxIcon_Open; }
        }

        private readonly List<MoneyInfo> moneyInfos = new();

        public List<MoneyInfo> MoneyInfos
        {
            get
            {
                return moneyInfos;
            }
        }

        public TreasureBoxData(DRTreasureBox dRTreasureBox)
        {
            this.dRTreasureBox = dRTreasureBox;
            moneyInfos = new();
            for (int i = 0; i < dRTreasureBox.MoneyOutputId.Length; i++)
            {
                MoneyOutputData moneyOutputData = GameEntry.Data.GetData<MoneyEntity>().GetMoneyOutputData(dRTreasureBox.MoneyOutputId[i]);
                moneyInfos.Add(new MoneyInfo(moneyOutputData.MoneyEntityId, moneyOutputData.dRMoneyOutput.RangeNum[0], moneyOutputData.dRMoneyOutput.RangeNum[1]));
            }
        }
    }
}
